home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / nftp102.zip / UPDINI.CMD < prev   
OS/2 REXX Batch file  |  1997-04-16  |  2KB  |  81 lines

  1. /* REXX */
  2.  
  3. parse arg oldini newini tmpini garbage
  4.  
  5. if (tmpini = "" ) | (garbage <> "") then signal usage
  6.  
  7. say
  8. say "Merging your customizations:"
  9. say "  from: " oldini 
  10. say "  into: " newini 
  11. say "  using:" tmpini " as a template"
  12. say
  13.  
  14. /* Load RexxUtil extensions */
  15. if RxFuncQuery("SysLoadFuncs") then do
  16.     say "loading RexxUtil extensions..."
  17.     call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  18.     if result \= "0" then do
  19.         say "error loading RexxUtil.dll"
  20.         exit
  21.     end
  22.     call SysLoadFuncs
  23. end
  24.  
  25. /* read old 'nftp.ini' and gather meaningful strings in it */
  26. /*say "Your customized lines to be migrated into new file :"
  27. say copies("-", 70)*/
  28. signal off notready
  29. i = 0
  30. do forever
  31.     lin = linein(oldini)
  32.     if (left(lin,1) <> "[") & (left(lin,1) <> ";") & (verify(lin, " ") <> 0) then 
  33.        do
  34.          input.i = lin
  35.          i = i + 1
  36.        end
  37.     if lin = "" & left(stream(oldini),5) <> "READY" then leave
  38. end
  39. call stream oldini, "C", "CLOSE"
  40. nlines = i
  41. /*say copies("-", 70)*/
  42.  
  43. /* updating ooooold things */
  44.  
  45. do i = 0 to nlines-1
  46.    if substr(input.i, 1, 15) = "bookmarks-file=" then
  47.       do
  48.         n = pos(".mrk", input.i)
  49.         if n <> 0 then input.i = overlay(".bmk", input.i, n)
  50.       end
  51. end
  52.  
  53. /* filter out new file and merge customizations into it */
  54. Call SysFileDelete newini
  55. do forever
  56.     lin = linein(tmpini)
  57.     ln = pos("=", lin)
  58.     if left(lin,1) = ";" & length(lin) > 1 & ln > 1 then
  59.     do i = 0 to nlines-1
  60.         if substr(lin, 2, ln-1) = left(input.i,ln-1) then
  61.         do
  62.             say "updating" input.i
  63.             lin = input.i
  64.         end
  65.     end
  66.     rc = lineout(newini, lin)
  67.     if lin = "" & left(stream(tmpini),5) <> "READY" then leave
  68. end
  69. call stream tmpini, "C", "CLOSE"
  70. call stream newini, "C", "CLOSE"
  71.  
  72. return
  73.  
  74. usage:
  75.     
  76.     say
  77.     say "Usage: updini <old-nftp.ini> <new-nftp.ini> <template-nftp.ini>"
  78.     say "Merges old and new NFTP.INIs. All parameters are obligatory."
  79.  
  80.     exit 1
  81.